/*测试数据*/
var testdata=[
	{
		id: 1,
		orederID: 'dfgdf3333',
		productID: 3434554,
		productBrand: 'lisd',
		productName: '上海新区',
		productVersion: '上海市浦东新区',
		singlePrice:230,
		orderState:2001,
		deleted:0,
		isPayment:0,
		shoppingAddress:'上海市浦东新区aa',
		createTime: 1502937009,
		payTime: 1502937009,
		number:2,
		totalPrice: 468,
		realName:"alal",
		phone:18817802281,
		taxStatus: 1,
		taxNumber: 'CX454544',
		taxNumber: 468,
		fareStatus: 1,
		fareType: '自提'//自提/送货
	},
	{
		id: 2,
		orederID: 'dfgdf3333',
		productID: 3434554,
		productBrand: 'lisd',
		productName: '上海新区',
		productVersion: '上海市浦东新区',
		singlePrice:230,
		orderState:2002,
		deleted:0,
		isPayment:1,
		shoppingAddress:'上海市浦东新区aa',
		createTime: 1502937009,
		payTime: 1502937009,
		number:2,
		totalPrice: 468,
		realName:"alal",
		phone:18817802281,
		taxStatus: 0,
		taxNumber: 'CX454544',
		taxNumber: 468,
		fareStatus: 0,
		fareType: '送货'//自提/送货
	},
	{
		id: 3,
		orederID: 'dfgdf3333',
		productID: 3434554,
		productBrand: 'lisd',
		productName: '上海新区',
		productVersion: '上海市浦东新区',
		singlePrice:230,
		orderState:2003,
		deleted:0,
		isPayment:1,
		shoppingAddress:'上海市浦东新区aa',
		createTime: 1502937009,
		payTime: 1502937009,
		number:2,
		totalPrice: 468,
		realName:"alal",
		phone:18817802281,
		taxStatus: 0,
		taxNumber: 'CX454544',
		taxNumber: 468,
		fareStatus: 0,
		fareType: '送货'//自提/送货
	},
	{
		id: 4,
		orederID: 'dfgdf3333',
		productID: 3434554,
		productBrand: 'lisd',
		productName: '上海新区',
		productVersion: '上海市浦东新区',
		singlePrice:230,
		orderState:2004,
		deleted:0,
		isPayment:1,
		shoppingAddress:'上海市浦东新区aa',
		createTime: 1502937009,
		payTime: 1502937009,
		number:2,
		totalPrice: 468,
		realName:"alal",
		phone:18817802281,
		taxStatus: 0,
		taxNumber: 'CX454544',
		taxNumber: 468,
		fareStatus: 0,
		fareType: '送货'//自提/送货
	}
];
var testoneitem={
		id: 2,
		orederID: 'dfgdf3333',
		productID: 3434554,
		productBrand: 'lisd',
		productName: '上海新区',
		productVersion: '上海市浦东新区',
		singlePrice:230,
		state:2004,
		deleted:0,
		isPayment:1,
		shoppingAddress:'上海市浦东新区aa',
		createTime: 1502937009,
		payTime: 1502937009,
		number:2,
		totalPrice: 468,
		realName:"alal",
		phone:18817802281,
		taxStatus: 0,
		taxNumber: 'CX454544',
		taxNumber: 468,
		fareStatus: 0,
		fareType: '送货'//自提/送货
	};



$(function(){
	var tgid=-1;
	if(getUrlParam("tgid")!=null && getUrlParam("tgid")!=""){
		tgid=getUrlParam("tgid");
	}
	getTableData();
	$("#searchBtn").on('click',function () {
        getTableData();
    });
    $("#btnExcel").on('click',function () {
        getExcelData();
    });
	/*$("#orderStateST").unbind().change(function(){
		var tgid=-1;
		if(getUrlParam("tgid")!=null && getUrlParam("tgid")!=""){
			tgid=getUrlParam("tgid");
		}
		var orderStateST = $("#orderStateST").val();
		var taxStatusST = $("#taxStatusST").val();
		getTableData(tgid,orderStateST,taxStatusST);
	});*/
	/*$("#taxStatusST").unbind().change(function(){
		var tgid=-1;
		if(getUrlParam("tgid")!=null && getUrlParam("tgid")!=""){
			tgid=getUrlParam("tgid");
		}
		var orderStateST = $("#orderStateST").val();
		var taxStatusST = $("#taxStatusST").val();
		getTableData(tgid,orderStateST,taxStatusST);
	});*/
    /*console.log(digitUppercase(29200.00));*/
});
function getExcelData(){
    var params ={};
    userId=getUrlParam("tgid") || '';
    var orderStateST = $("#orderStateST").val();
    var taxStatusST = $("#taxStatusST").val();
    var theStartTme = $("#startTime").val();
    var theEndTime = $("#endTime").val();
    if(theStartTme!=null && theStartTme!=""){
        theStartTme = Date.parse(new Date(theStartTme));
        theStartTme = theStartTme;
    }else{
        theStartTme = 0;
    }
    if(theStartTme!=null && theStartTme!=""){
        theEndTime = Date.parse(new Date(theEndTime));
        theEndTime = theEndTime;
    }else{
        theEndTime = 0;
    }
    if(theStartTme!=0 && theEndTime!=0){
        var nday = daysBetween(theStartTme,theEndTime);
        if(nday<=0){
            consoleMes($("#manageContent"),2000,"warning","开始时间和结束时间至少相差一天！");//success、info、warning、danger
            return;
        }
    }
    var tsearchType = $("#tsearchType").val();
    var keyword = $("#keyword").val();
    if(tsearchType=="订单编号"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'orderId': keyword
        }
    }else if(tsearchType=="收货地址"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'shoppingAddress': keyword
        }
    }else if(tsearchType=="收货人姓名"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'realName': keyword
        }
    }else if(tsearchType=="联系电话"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'userPhone': keyword
        }
    }

    $.post(
        gobalServer+"order/downloadOrderByQueryCondition",
        params,
        function(backData){
            if(backData.statusCode==200){
                consoleMes($("#manageContent"),2000,"success","正在导出excel文件！");
                window.open(gobalDownUrl+backData.msg);
            }else{
                consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

            }
        }
    );

}
/*获取表格数据*/
/*function getTableData(tgid,orderState,taxStatus){
	/!*var backData=testdata;//[];
	tableInit(backData);*!/
	var selectObject={};
    if(getUrlParam("tgid")==null){
        tgid=getUrlParam("tgid");
    }else{
        if(tgid=="-1"){
            consoleMes($("#manageContent"),2000,"warning","无该用户相关订单！");
        }else{
        }
        selectObject.userId=tgid;
	}

    if(orderState>-1){
        selectObject.orderState=orderState;
    }
    if(taxStatus>-1){
        selectObject.taxStatus=taxStatus;
    }
    $.post(
        gobalServer+"order/select",
        selectObject,
        function(backData){
            if(backData.statusCode==200){
                var backData=backData.commonList;//[];
				if(backData.length<=0){
					consoleMes($("#manageContent"),2000,"warning","无该用户相关订单！");
				}
                tableInit(backData);
            }else{
                consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

            }
        }
    );

};*/
function getTableData(){
    var params ={};
    userId=getUrlParam("tgid") || '';
    var orderStateST = $("#orderStateST").val();
    var taxStatusST = $("#taxStatusST").val();
    var theStartTme = $("#startTime").val();
    var theEndTime = $("#endTime").val();
    if(theStartTme!=null && theStartTme!=""){
        theStartTme = Date.parse(new Date(theStartTme));
        theStartTme = theStartTme;
    }else{
        theStartTme = 0;
    }
    if(theStartTme!=null && theStartTme!=""){
        theEndTime = Date.parse(new Date(theEndTime));
        theEndTime = theEndTime;
    }else{
        theEndTime = 0;
    }
    if(theStartTme!=0 && theEndTime!=0){
        var nday = daysBetween(theStartTme,theEndTime);
        if(nday<=0){
            consoleMes($("#manageContent"),2000,"warning","开始时间和结束时间至少相差一天！");//success、info、warning、danger
            return;
        }
    }
    var tsearchType = $("#tsearchType").val();
    var keyword = $("#keyword").val();
    if(tsearchType=="订单编号"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
			'orderId': keyword
        }
	}else if(tsearchType=="收货地址"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'shoppingAddress': keyword
        }
    }else if(tsearchType=="收货人姓名"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'realName': keyword
        }
    }else if(tsearchType=="联系电话"){
        params = {
            'selectedUserId': userId,
            'orderState': orderStateST,
            'taxStatus': taxStatusST,
            'startTime': theStartTme,
            'endTime': theEndTime,
            'userPhone': keyword
        }
    }

    $.post(
        gobalServer+"order/query",
        params,
        function(backData){
            if(backData.statusCode==200){
                var backData=backData.pageBean.list;//[];
                if(backData.length<=0){
                    consoleMes($("#manageContent"),2000,"warning","无该用户相关订单！");
                }
                tableInit(backData);
            }else{
                consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

            }
        }
    );

}
/*表格初始化*/
function tableInit(backData){
	var objectArray=[];
    if(backData.length>0){
        objectArray=dataToJson(backData);
    }
    $('#stockTable').bootstrapTable('destroy').bootstrapTable({
        toolbar: '#toolbar',                //工具按钮用哪个容器
        pageNumber:1,                       //初始化加载第一页，默认第一页
        pageSize: 20,                       //每页的记录行数（*）
        minimumCountColumns: 2,             //最少允许的列数
        clickToSelect: true,                //是否启用点击选中行
        height: 500,                        //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        data: objectArray,
        pageList: [5, 10, 20, 40, 100, 200]/*,
        rowStyle: function rowStyle(row,index) {
            if(row.mark!=null && row.mark>0){
                return {
                    css:{
                        "background-color": "#ffc930",
                        "color": "#fff"
                    }
                };
            }else{
                return {
                    css:{

                    }
                };
            }
        }*/
    });
};
/*表格数据封装*/
function dataToJson(dataResult) {
    var objectArray=new Array();
    $.each(dataResult,function(index,item){
    	var createTime="--";
    	if(item.createTime!=null){
        	createTime=formatDateTimeYMDHMS(item.createTime);
        }
        var totalPrice="";
        if(item.totalPrice!=null){
        	totalPrice="<b class='text-red'>￥"+item.totalPrice+"</a>";
        }
        
        var payTime="--";
    	if(item.payTime!=null){
        	payTime=formatDateTimeYMDHMS(item.payTime);
        }
        
        /*var printMes="";
        printMes="<a class='btn-a-common' href='javascript:;' onclick='getPrintMesDetail("+item.id+")' >打印</a>";*/
        
        var orderMes="";
        orderMes="<a class='btn-a-common' href='javascript:;' tgid='"+item.orderId+"' onclick='getOrderMesDetail(this)' >查看</a>";
        var operate="";
        operate="<a class='btn-a-common' href='javascript:;' tgid='"+item.orderId+"' onclick='deleteItemData(this)'>删除</a>";

        /*var isPayment="";
    	if(item.paymentStatus!=null && item.paymentStatus==0){
        	isPayment="未支付";
       	}else if(item.paymentStatus!=null && item.paymentStatus==1){
       		isPayment="已支付";
        }*/
       	
       	var taxStatus="";
    	if(item.taxStatus!=null && item.taxStatus==1){
            taxStatus="已开";
       	}else{
            taxStatus="未开";
        }
       	
        var orderState="";
    	if(item.orderState!=null && item.orderState==2001){
        	orderState="待支付";
        }else if(item.orderState!=null && item.orderState==2002){
        	orderState="待确认";
        }else if(item.orderState!=null && item.orderState==2003){
        	orderState="待发货";
        }else if(item.orderState!=null && item.orderState==2004){
        	orderState="关闭";
        }

        if(item.orderState!=null && item.orderState==2001){

        }

        if(item.orderState!=null && item.orderState==2002){
			operate+="<a class='btn-a-common' href='"+gobalWeb+"orders/editorder.html?tgid="+item.orderId+"'>修改</a>";
        	operate+="<a class='btn-a-common' href='javascript:;' tgid='"+item.orderId+"' onclick='editOrderState(this,2003)'>确认</a>";
            operate+="<a class='btn-a-common' href='javascript:;' tgid='"+item.orderId+"' onclick='cancelOrderState(this,"+item.orderState+")'>取消</a>";
        }
        
        if(item.orderState!=null && item.orderState==2003){
        	operate+="<a class='btn-a-common' href='javascript:;'  tgid='"+item.orderId+"' onclick='createShip(this)'>发货</a>";
        }
        
        if(item.orderState!=null && item.orderState>=2003){
        	operate+="<a class='btn-a-common' href='javascript:;' tgid='"+item.orderId+"' onclick='createTax(this)'>开票</a>";
        }

        
        /*operate+="<a class='btn-a-common' href='javascript:;' tgid='"+item.orderId+"' onclick='getPrintMesDetail(this)' >打印</a>";*/
        operate+="<a class='btn-a-common' href='"+gobalWeb+"orders/print.html?tgid="+item.orderId+"' target='_blank'>打印</a>";
        var arr={
        	"id":item.id,
        	"orederID":item.orderId,
            /*"productName":item.productName,*/
            "totalPrice":totalPrice,
            "shoppingAddress":item.shoppingAddress,           
            "orderMes":orderMes,
            /*"printMes":printMes,*/
            /*"isPayment":isPayment,*/
            "orderState":orderState,
            "taxStatus":taxStatus,
            "userId":item.userId,
            "createTime":createTime,
            /*"payTime":payTime,*/
            "operate":operate
        };
        objectArray.push(arr);
    });
    return objectArray;
};
/*删除数据*/
function deleteItemData(obj){
    var tgid= $(obj).attr("tgid");
    if(tgid!=null && tgid!=""){
		var msg = "您真的确定要删除吗？\n\n删除后无法撤回！";
		if (confirm(msg)==true){
			/*consoleMes($("#manageContent"),2000,"success","数据已经成功删除！");
        	setTimeout(function () {
		    	window.location.reload();
		    }, 2500);*/
            $.post(
                gobalServer+"order/delete",
                {"orderId":tgid},
                function(backData){
                    if(backData.statusCode==200){
                        consoleMes($("#manageContent"),2000,"success",backData.msg);
                        setTimeout(function () {
                            window.location.reload();
                        }, 2500);
                    }else{
                        consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                    }
                }
            );
		}
	}else{
		consoleMes($("#manageContent"),2000,"warning","删除失败，请刷新页面重试！");//success、info、warning、danger
	}
};
/*取消订单*/
function cancelOrderState(obj,orderState){
    var tgid= $(obj).attr("tgid");
    if(tgid!=null && tgid!="" && orderState!=null && orderState!=""){
        var msg = "您真的确定要取消订单吗？\n\n确认后无法撤回！";
        if (confirm(msg)==true){
			/*consoleMes($("#manageContent"),2000,"success","数据已经成功删除！");
			 setTimeout(function () {
			 window.location.reload();
			 }, 2500);*/
            $.post(
                gobalServer+"order/cancel",
                {"orderId":tgid,"orderState":orderState},
                function(backData){
                    if(backData.statusCode==200){
                        consoleMes($("#manageContent"),2000,"success",backData.msg);
                        setTimeout(function () {
                            window.location.reload();
                        }, 2500);
                    }else{
                        consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                    }
                }
            );
        }
    }else{
        consoleMes($("#manageContent"),2000,"warning","删除失败，请刷新页面重试！");//success、info、warning、danger
    }
};
/*改变订单状态*/
function editOrderState(obj,orderState){
    var tgid= $(obj).attr("tgid");
	if(tgid!=null && tgid!="" && orderState!=null && orderState!=""){
		var msg = "您真的确定执行该操作吗？\n\n执行后无法撤回！";
		if (confirm(msg)==true){
			/*consoleMes($("#manageContent"),2000,"success","操作成功！");
        	setTimeout(function () {
		    	window.location.reload();
		    }, 2500);*/
            $.post(
                gobalServer+"order/update",
                {"orderId":tgid,"orderState":orderState},
                function(backData){
                    if(backData.statusCode==200){
                        consoleMes($("#manageContent"),2000,"success",backData.msg);
                        setTimeout(function () {
                            window.location.reload();
                        }, 2500);
                    }else{
                        consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                    }
                }
            );
		}
	}else{
		consoleMes($("#manageContent"),2000,"warning","删除失败，请刷新页面重试！");//success、info、warning、danger
	}
};
/*发货*/
function createShip(obj){
    var tgid= $(obj).attr("tgid");
    if(tgid!=null && tgid!=""){
		$("#shipModal").modal('show');
		/*发货操作*/
		$("#btnCreateShip").on('click',function(){
			var fareType=$("#fareTypeST").val().trim();
			if(fareType==null || fareType==""){
				consoleMes($("#manageContent"),2000,"warning","请选择发货类型！");
				return;
			}
			/*consoleMes($("#manageContent"),2000,"success","操作成功！");
        	setTimeout(function () {
		    	window.location.reload();
		    }, 2500);*/
            $.post(
                gobalServer+"order/updateOrderFare",
                {"orderId":tgid,"orderState":2004,"fareType":fareType,"fareStatus":1},
                function(backData){
                    if(backData.statusCode==200){
                        consoleMes($("#manageContent"),2000,"success",backData.msg);
                        setTimeout(function () {
                            window.location.reload();
                        }, 2500);
                    }else{
                        consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                    }
                }
            );

		});
	}else{
		consoleMes($("#manageContent"),2000,"warning","删除失败，请刷新页面重试！");//success、info、warning、danger
	}
};
/*开票*/
function createTax(obj){
    var tgid= $(obj).attr("tgid");
    if(tgid!=null && tgid!=""){
		$("#taxModal").modal('show');
		/*发货操作*/
		$("#btnCreateTax").on('click',function(){
			var taxNumber=$("#taxNumberST").val().trim();
			var taxMoney=$("#taxMoneyST").val().trim();
			if(taxNumber==null || taxNumber==""){
				consoleMes($("#manageContent"),2000,"warning","请输入发票号码！");
				return;
			}
			if(taxMoney==null || taxMoney<=0){
				consoleMes($("#manageContent"),2000,"warning","请输入开票金额！");
				return;
			}
			/*consoleMes($("#manageContent"),2000,"success","操作成功！");
	    	setTimeout(function () {
		    	window.location.reload();
		    }, 2500);*/
            $.post(
                gobalServer+"order/update",
                {"orderId":tgid,"taxStatus":1,"taxNumber":taxNumber,"taxMoney":taxMoney},
                function(backData){
                    if(backData.statusCode==200){
                        consoleMes($("#manageContent"),2000,"success",backData.msg);
                        setTimeout(function () {
                            window.location.reload();
                        }, 2500);
                    }else{
                        consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                    }
                }
            );

	    });
	}else{
		consoleMes($("#manageContent"),2000,"warning","删除失败，请刷新页面重试！");//success、info、warning、danger
	}
};
/*查看订单详情*/
function getOrderMesDetail(obj){
    var tgid= $(obj).attr("tgid");
    if(tgid!=null && tgid!=""){
		/*var datarows=testoneitem;
		if(datarows!=null){
			$("#realName").text(datarows.realName);
			$("#phone").text(datarows.phone);
			$("#productBrand").text(datarows.productBrand);
			$("#productName").text(datarows.productName);
			$("#singlePrice").text(datarows.singlePrice);
			$("#productVersion").text(datarows.productVersion);
			if(datarows.isPayment!=null && datarows.isPayment==1){
				$("#isPayment").text("已支付");
			}else{
				$("#isPayment").text("未支付");
			}
			$("#number").text(datarows.number);
			var totalPrice="";
	        if(datarows.totalPrice!=null){
	        	totalPrice="<b class='text-red'>￥"+datarows.totalPrice+"</a>";
	        }
			$("#totalPrice").html(totalPrice);
			var payTime="--";
	    	if(datarows.payTime!=null){
	        	payTime=formatDateTimeYMDHMS(datarows.payTime);
	       }
			$("#payTime").text(payTime);
			/!*if(datarows.deleted!=null && datarows.deleted==1){
				$("#deleted").text("已删除");
			}else{
				$("#deleted").text("未删除");
			}*!/
			$("#orderModal").modal("show");
		}else{
			consoleMes($("#manageContent"),2000,"warning","无法获取数据，请刷新重试！");
		}*/
        $.post(
            gobalServer+"order/selectOne",
            {"orderId":tgid},
            function(backData){
                if(backData.statusCode==200){
                    var datarows=backData.object;
                    if(datarows!=null){
                        if(datarows.orderId!=null && datarows.orderId!=""){
                            getOrderDetailList(datarows.orderId);
                        }
                    	if(datarows.userId!=null && datarows.userId!=""){
                            $("#userIdCode").text("-用户编号："+datarows.userId);
						}
                        $("#userPhone").text(datarows.userPhone);
                        $("#userPhone").text(datarows.userPhone);
                        $("#realName").text(datarows.realName);
                        /*$("#productBrand").text(datarows.productBrand);
                        $("#productName").text(datarows.productName);
                        $("#singlePrice").text("￥"+datarows.singlePrice);
                        $("#productVersion").text(datarows.productVersion);*/
                        /*$("#number").text(datarows.number);*/
                        $("#totalPrice").text("￥"+datarows.totalPrice);
                        var payTime="--";
                        if(datarows.payTime!=null){
                            payTime=formatDateTimeYMDHMS(datarows.payTime);
                        }
                        $("#payTime").text(payTime);
                        $("#shoppingAddress").text(datarows.shoppingAddress);
                        $("#orderRemark").text(datarows.orderRemark);
                       /* if(datarows.paymentStatus!=null && datarows.paymentStatus==1){
                            $("#isPayment").text("已支付");
                        }else{
                            $("#isPayment").text("未支付");
                        }*/
                        /*if(datarows.deleted!=null && datarows.deleted==1){
                            $("#deleted").text("已删除");
                        }else{
                            $("#deleted").text("未删除");
                        }*/
                        if(datarows.orderState==2004){
                            $("#hasShip").text("已发货");
                            $("#fareType").text(datarows.fareType);
                            if(datarows.fareStatus!=null && datarows.fareStatus==1){
                                $("#fareStatus").text("已收货");
                            }else{
                                $("#fareStatus").text("未收货");
							}
                            var fareTime="--";
                            if(datarows.fareTime!=null && datarows.fareTime!="" && datarows.fareTime!=0){
                                fareTime=formatDateTimeYMDHMS(datarows.fareTime);
                            }else {
								fareTime = formatDateTimeYMDHMS(fareTime);
							}
                            /*fareTime=fareTime.substr(0,fareTime.indexOf(" "));*/
                            $("#fareTime").text(fareTime);
							$("#hasShipGroup").show();
						}
                        if(datarows.taxStatus==1){
                            $("#hasShip").text("已开票");
                            $("#taxNumber").text(datarows.taxNumber);
                            $("#taxMoney").text(datarows.taxMoney);
                            $("#taxGroup").show();
                        }
                        $("#orderModal").modal("show");
                    }else{
                        consoleMes($("#manageContent"),2000,"warning","无法获取数据，请刷新重试！");
                    }
                }else{
                    consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                }
            }
        );

	}else{
		consoleMes($("#manageContent"),2000,"warning","无法查看，请刷新页面重试！");//success、info、warning、danger
	}
};
/*获取订单详情*/
function getOrderDetailList(tid) {
	if(tid!=null && tid!=""){
        $.post(
            gobalServer+"order/selectOrderDetailByOrderId",
            {"orderId":tid},
            function(backData){
                if(backData.statusCode==200){
                    var datarows=backData.commonList;
                    $("#orderDetailList").empty();
                    if(datarows.length>0){
						$.each(datarows,function (i,item) {
                            $productId=$("<td>").text(item.productId);
                            $productName=$("<td>").text(item.productName);
                            $productBrand=$("<td>").text(item.productBrand);
                            $productVersion=$("<td>").text(item.productVersion);
                            $singlePrice=$("<td>").text("￥"+item.singlePrice.toFixed(2));
                            $number=$("<td>").text(item.number);
                            $tr=$("<tr>");
                            $tr.append($productId,$productName,$productBrand,$productVersion,$singlePrice,$number);
                            $("#orderDetailList").append($tr);
                        });
                    }else{
                        $td=$("<td>").addClass("text-center").attr({"colspan":6}).text("暂无订单产品信息！");
                        $tr=$("<tr>");
                        $tr.append($td);
						$("#orderDetailList").append($tr);
                    }
                }else{
                    consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                }
            }
        );
	}else {
        consoleMes($("#manageContent"),2000,"warning","无法获取订单详情信息，请刷新页面重试！");//success、info、warning、danger
	}
}
/*打印单详情*/
function getPrintMesDetail(obj){
    var tgid= $(obj).attr("tgid");
    if(tgid!=null && tgid!=""){
		/*var datarows=testoneitem;
		if(datarows!=null){
			btnPrintOrder();
			$("#printModal").modal("show");
		}else{
			consoleMes($("#manageContent"),2000,"warning","无法获取数据，请刷新重试！");
		}*/
        $.post(
            gobalServer+"order/selectOne",
            {"orderId":tgid},
            function(backData){
                if(backData.statusCode==200){
                    var datarows=backData.object;
                    if(datarows!=null){
						$("#taxNumberpt").text(datarows.taxNumber);
                        var fareTime="--";
                        if(datarows.fareTime!=null){
                            fareTime=formatDateTimeYMDHMS(datarows.fareTime);
                        }
                        fareTime=formatDateTimeYMDHMS(fareTime);
                        fareTime=fareTime.substr(0,fareTime.indexOf(" "));
                        $("#deliveryTimept").text(fareTime);
                        $("#userIdpt").text(datarows.userId);
                        $("#realNamept").text(datarows.realName);
                        $("#userPhonept").text(datarows.userPhone);
                        $("#fareTypept").text(datarows.orderId);
                        $("#shoppingAddresspt").text(datarows.shoppingAddress);
                        /*$("#productIdpt").text(datarows.productId);
                        $("#productNamept").text(datarows.productName);
                        $("#productVersionpt").text(datarows.productVersion);
                        $("#numberpt").text(datarows.number);
                        $("#singlePricept").text(datarows.singlePrice.toFixed(2));*/
                        /*$("#totalPricept").text(datarows.totalPrice.toFixed(2));
                        $("#allNumber").text(datarows.number);
                        $("#allTotal").text(datarows.totalPrice.toFixed(2));
                        $("#allTotalUP").text(digitUppercase(datarows.totalPrice.toFixed(2)));*/
                        var printDate = timeStamp2String(new Date());
                        printDate=printDate.substr(0,printDate.indexOf(" "));
                        $("#printDate").text(printDate);
                        if(datarows.orderId!=null && datarows.orderId!=""){
                            getPrintOrderDetailList(datarows.orderId,datarows.totalPrice);
                        }
                        /*btnPrintOrder();
                        $("#printModal").modal("show");*/
                    }else{
                        consoleMes($("#manageContent"),2000,"warning","无法获取数据，请刷新重试！");
                    }
                }else{
                    consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                }
            }
        );

	}else{
		consoleMes($("#manageContent"),2000,"warning","无法查看，请刷新页面重试！");//success、info、warning、danger
	}
};
/*获取打印订单详情*/
function getPrintOrderDetailList(tid,totalPrice) {
    if(tid!=null && tid!=""){
        $.post(
            gobalServer+"order/selectOrderDetailByOrderId",
            {"orderId":tid},
            function(backData){
                if(backData.statusCode==200){
                    var datarows=backData.commonList;
                    $("#printOrderDetailList").empty();
                    if(datarows.length>0){
                    	var totalNum=0;
                        $.each(datarows,function (i,item) {
                            $productId=$("<td>").text(item.productId);
                            $productName=$("<td>").text(item.productName);
                            $productVersion=$("<td>").text(item.productVersion);
                            $unit=$("<td>").text("套");
                            $number=$("<td>").text(item.number);
                            totalNum+=item.number;
                            $singlePrice=$("<td>").text(item.singlePrice.toFixed(2));
                            $totalPrice=$("<td>").text((item.singlePrice*item.number).toFixed(2));
                            $tr=$("<tr>");
                            $tr.append($productId,$productName,$productVersion,$unit,$number,$singlePrice,$totalPrice);
                            $("#printOrderDetailList").append($tr);
                        });
                        $td1=$("<td>").text("合计数量：");
                        $td2=$("<td>").attr({"colspan":3});
                        $number=$("<td>").text(totalNum);
                        $td3=$("<td>");
                        $totalPrice=$("<td>").text(totalPrice.toFixed(2));
                        $tr1=$("<tr>");
                        $tr1.append($td1,$td2,$number,$td3,$totalPrice);
                        $("#printOrderDetailList").append($tr1);
                        $td3=$("<td>").text("合计金额");
                        $totalPriceUP=$("<td>").attr({"colspan":6}).text(digitUppercase(totalPrice.toFixed(2)));
                        $tr2=$("<tr>");
                        $tr2.append($td3,$totalPriceUP);
                        $("#printOrderDetailList").append($tr2);
                        $td4=$("<td>").text("备注");
                        $remark=$("<td>").attr({"colspan":6});
                        $tr3=$("<tr>");
                        $tr3.append($td4,$remark);
                        $("#printOrderDetailList").append($tr3);
                    }
                    btnPrintOrder();
                    $("#printModal").modal("show");
                }else{
                    consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                }
            }
        );
    }else {
        consoleMes($("#manageContent"),2000,"warning","无法获取订单详情信息，请刷新页面重试！");//success、info、warning、danger
    }
}
//打印订单信息
function btnPrintOrder(){
	$("#btnPrintOrder").on('click',function(){
		$("#printModal").modal("hide");
		printHtml($("#printOrderTable"));
		window.location.reload();
	});
};